package com.boot.cluster.worker.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;


public class TaskWrap extends Pair<TaskRunner,List<TaskSplitterInfo>> implements Serializable{
	private static final long serialVersionUID = 4813403303489833741L;

	private TaskRunner runner;

	private List<TaskSplitterInfo> tasks;

	public List<TaskSplitterInfo> getTasks() {
		return this.tasks;
	}

	public void setTasks(List<TaskSplitterInfo> tasks) {
		this.tasks = tasks;
	}

	public void addTaskInfo(TaskSplitterInfo info) {
		if((this.tasks==null) || this.tasks.isEmpty()) {
			this.tasks =new ArrayList<>();
		}
		this.tasks.add(info);
	}
	public void addTaskInfo(TaskSplitterInfo... infos) {
		if((this.tasks==null) || this.tasks.isEmpty()) {
			this.tasks =new ArrayList<>();
		}
		this.tasks.addAll(Arrays.asList(infos));
	}

	public void addTaskInfo(Collection<TaskSplitterInfo> infos) {
		if(this.tasks==null) {
			this.tasks =new ArrayList<>();
		}
		this.tasks.addAll(infos);
	}

	public TaskRunner getRunner() {
		return this.runner;
	}

	public void setRunner(TaskRunner runner) {
		this.runner = runner;
	}

}
